package com.service;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.omg.CORBA.Request;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.adminDaoImpl;
import com.entity.Admins;
import com.entity.User;

@Service
@Transactional
public class AdminServiceImpl {
	@Resource
	public adminDaoImpl aDaoImpl;
	
	//登录
	public boolean AdminByNameAndPwd(String name,String password, HttpSession session){
		if(this.aDaoImpl.adminByNameAndPW(name, password)){
			session.setAttribute("name", name);
			return true;
		}else {
			return false;	
		}
	}
	public boolean AdminByName(String name){
		if(this.aDaoImpl.adminByName(name)){
			return true;
		}else {
			return false;
		}
	}
	//修改管理员信息
	public void updateAdmin(Admins a){
		aDaoImpl.updateadmin(a);
	}
	
	//查询所以用户
	public List<User> findAllUser(){
		return aDaoImpl.findAllUser();
	}
	//id查询用户
	public User findUserById(int id){
		User user =aDaoImpl.findUserById(id);
		return user;
	}
	//修改用户信息
	public void updateUser(User u){
		aDaoImpl.updateUser(u);
	}
	//删除用户
	public void deleteUser(int id){
		User user=aDaoImpl.findUserById(id);
		aDaoImpl.deletUser(user);
	}

}
